//
//  UIColor+ICT.m
//  iCareTek
//
//  Created by ren yi on 4/30/14.
//  Copyright (c) 2014 iCareTech. All rights reserved.
//

#import "UIColor+ICT.h"

@implementation UIColor (ICT)
+ (UIColor*) colorWithHex:(NSInteger)hexValue alpha:(CGFloat)alphaValue
{
    return [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0
                           green:((float)((hexValue & 0xFF00) >> 8))/255.0
                            blue:((float)(hexValue & 0xFF))/255.0 alpha:alphaValue];
}

+ (UIColor*) colorWithHex:(NSInteger)hexValue
{
    return [UIColor colorWithHex:hexValue alpha:1.0];
}

+ (UIColor*)trendsNormalColor
{
    return [UIColor colorWithRed:7.0/255.0 green:114.0/255.0 blue:162.0/255.0 alpha:1.0];
}

+ (UIColor*)trendsUnNormalColor
{
    return [UIColor colorWithRed:222.0/255.0 green:138.0/255.0 blue:7.0/255.0 alpha:1.0];
}

+ (UIColor*)coloumnNormalColor
{
    return [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.8];
}

+ (UIColor*)dynamicUpViewBackgroundColorWithThemeName:(NSString*)themeName
{
    if ([themeName isEqualToString:@"default"]) {
        return [UIColor colorWithRed:58.0f/255.0f
                               green:117.0f/255.0f
                                blue:156.0f/255.0f
                               alpha:1.0f];
    }
    else if ([themeName isEqualToString:@"lightGreen"])
    {
        return [UIColor colorWithRed:81.0f/255.0f
                               green:129.0f/255.0f
                                blue:80.0f/255.0f
                               alpha:1.0f];
    }
    else if ([themeName isEqualToString:@"ceruleanBlue"])
    {
        return [UIColor colorWithRed:15.0f/255.0f
                               green:112.0f/255.0f
                                blue:189.0f/255.0f
                               alpha:1.0f];
    }
    else
    {
        return [UIColor colorWithRed:54.0f/255.0f
                               green:148.0f/255.0f
                                blue:127.0f/255.0f
                               alpha:1.0f];
    }
}

- (UIColor *)withAlpha:(CGFloat)alpha
{
    CGColorRef colorRef = self.CGColor;
    
    CGFloat red = 0.0;
    CGFloat green = 0.0;
    CGFloat blue = 0.0;
    if (CGColorGetNumberOfComponents(colorRef) == 4)
    {
        const CGFloat *components = CGColorGetComponents(colorRef);
        red = components[0];
        green = components[1];
        blue = components[2];
    }
    
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}

@end
